/**
 * 装饰器模式
 */
#include <iostream>
#include <list>
#include <memory>

using namespace std;

// 抽象构件类Transform(变形金刚)
class Transform {
public:
    virtual void move() = 0;
};

// 具体构件类Car
class Car : public Transform {
public:
    Car() {
        cout << "变形金刚是一辆车！" << endl;
    }

    void move() {
        cout << "在陆地上移动。" << endl;
    }
};

// 抽象装饰类
class Changer : public Transform {
public:
    Changer(shared_ptr<Transform> transform) {
        this->transform = transform;
    }

    void move() {
        transform->move();
    }

private:
    shared_ptr<Transform> transform;
};

// 具体装饰类Robot
class Robot : public Changer {
public:
    Robot(shared_ptr<Transform> transform) : Changer(transform) {
        cout << "变成机器人!" << endl;
    }

    void say() {
        cout << "说话!" << endl;
    }
};

// 具体装饰类AirPlane
class Airplane : public Changer {
public:
    Airplane(shared_ptr<Transform> transform) : Changer(transform) {
        cout << "变成飞机!" << endl;
    }

    void say() {
        cout << "在天空飞翔!" << endl;
    }
};

// 客户端测试
int main(void) {
    shared_ptr<Transform> camaro = make_shared<Car>();
    camaro->move();
    cout << "--------------" << endl;
    shared_ptr<Robot> bumblebee = make_shared<Robot>(camaro);
    bumblebee->move();
    bumblebee->say();
    return 0;
}
